package com.greatwqs.wmall.message.consumer.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;

@Configuration
public class KafkaTopicConfig {

    public static final String TOPIC_NAME = "my-topic";
    public static final String TOPIC_PARTITIONED_NAME = "my-partitioned-topic";

    @Bean
    public NewTopic myTopic() {
        return TopicBuilder.name(TOPIC_NAME)
                .partitions(3)
                .replicas(1)
                .build();
    }

    @Bean
    public NewTopic myPartitionedTopic() {
        return TopicBuilder.name(TOPIC_PARTITIONED_NAME)
                .partitions(6)
                .replicas(1)
                .build();
    }
}